Skip to content

Conversation

@caohy1988
Copy link

@caohy1988 caohy1988 commented Jan 27, 2026

Summary

  • Add a comprehensive monitoring dashboard for ADK agent behavior analytics stored in BigQuery
  • FastAPI backend with real-time BigQuery queries for agent metrics
  • Embedded HTML/JS frontend with Chart.js visualizations
  • Support for Docker and Cloud Run deployment

Live Demo

🚀 Deployed Dashboard: https://agent-analytics-dashboard-201486563047.us-central1.run.app

Features

  • Overview Dashboard: Sessions, events, error rates, latency, token usage
  • Session Explorer: Browse and inspect individual conversation sessions with event traces
  • Tool Performance: Tool invocation rates, success/failure metrics, latency
  • LLM Metrics: Requests, tokens (prompt/completion), TTFT, latency trends
  • Latency Analysis: Percentiles (P50, P90, P95, P99), distribution histograms, slowest requests
  • Error Tracking: Aggregated error summaries with affected session counts

Screenshots

The dashboard includes 6 tabs:

  1. Overview - Key metrics cards and event distribution charts
  2. Sessions - Session list with click-to-view event traces
  3. Tools - Tool performance table with success rates
  4. LLM Performance - Token usage and latency metrics
  5. Errors - Aggregated error summaries
  6. Latency Analysis - Percentile metrics, distribution histogram, slowest requests

Files Added

  • contributing/samples/bigquery_agent_analytics_demo/dashboard/app.py - FastAPI dashboard application
  • contributing/samples/bigquery_agent_analytics_demo/dashboard/simulate_agent_data.py - Data simulation script
  • contributing/samples/bigquery_agent_analytics_demo/dashboard/Dockerfile - Container build
  • contributing/samples/bigquery_agent_analytics_demo/dashboard/docker-compose.yml - Docker orchestration
  • contributing/samples/bigquery_agent_analytics_demo/dashboard/requirements.txt - Dependencies
  • contributing/samples/bigquery_agent_analytics_demo/dashboard/README.md - Documentation
  • contributing/samples/bigquery_agent_analytics_demo/agent.py - Demo agent with BigQuery plugin

Test plan

  • Run dashboard locally with uvicorn app:app --port 8080
  • Verify all API endpoints return correct data
  • Test data simulation with python simulate_agent_data.py --num-sessions 10
  • Deploy to Cloud Run and verify public access
  • Confirm dashboard shows only ADK events (no GRAPH_END, NODE_COMPLETED, etc.)

🤖 Generated with Claude Code

Add a comprehensive monitoring dashboard for ADK agent behavior analytics
stored in BigQuery. The dashboard provides real-time insights into:

- Agent sessions and invocations
- LLM performance metrics (latency, tokens, TTFT)
- Tool usage and success rates
- Error tracking and analysis
- Latency analysis with percentiles (P50, P90, P95, P99)

Components:
- FastAPI backend with BigQuery queries
- Embedded HTML/JS frontend with Chart.js visualizations
- Data simulation script for testing
- Docker and Cloud Run deployment support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@google-cla
Copy link

google-cla bot commented Jan 27, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jan 27, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Jan 27, 2026

Response from ADK Triaging Agent

Hello @caohy1988, thank you for creating this PR!

Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). You can find more information at https://cla.developers.google.com/.

In addition, this PR is a new feature, could you please associate a GitHub issue with this PR? If there is no existing issue, could you please create one?

This information will help reviewers to review your PR more efficiently. Thanks!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @caohy1988, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adds a new BigQuery Agent Analytics Dashboard, providing a real-time monitoring solution for ADK agent behavior. It includes a FastAPI backend, an HTML/JS frontend with visualizations, and supports Docker and Cloud Run deployment. The dashboard offers insights into agent performance, tool usage, error tracking, and session analysis, enabling better observability and debugging.

Highlights

  • New Feature: Introduces a comprehensive monitoring dashboard for ADK agent behavior analytics stored in BigQuery, enhancing observability and debugging capabilities.
  • Backend: Implements a FastAPI backend with real-time BigQuery queries to fetch and process agent metrics efficiently.
  • Frontend: Includes an embedded HTML/JS frontend with Chart.js visualizations, providing an interactive and informative user interface.
  • Deployment: Offers support for Docker and Cloud Run deployment, simplifying the setup and scaling of the dashboard.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a great addition! A comprehensive analytics dashboard is a very valuable tool for monitoring and understanding agent behavior. The FastAPI backend is well-structured with clear API endpoints, and the inclusion of a data simulation script and Docker support makes it easy to get started.

My review focuses on a few key areas to improve maintainability and performance:

  • Separating the frontend code (HTML/JS/CSS) from the Python backend to make it easier to manage.
  • Optimizing the BigQuery client instantiation to improve API performance.
  • Aligning a default configuration value to prevent potential data discrepancies between the agent and the dashboard.

Overall, this is a fantastic feature. The changes I've suggested should help make it even more robust and maintainable.

Comment on lines +1166 to +1167
def get_dashboard_html() -> str:
"""Return the dashboard HTML with embedded JavaScript."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The get_dashboard_html function embeds a very large block of HTML, CSS, and JavaScript as a multiline string. This makes the frontend code extremely difficult to read, maintain, and debug. It also prevents developers from using standard frontend development tools like linters, formatters, and syntax highlighting.

For better maintainability, I strongly recommend separating the frontend assets from the Python code:

  1. Create a templates directory and move the HTML into a file like dashboard.html. Use a templating engine like Jinja2 to serve it.
  2. Create a static directory for your CSS and JavaScript files.
  3. Use FastAPI's StaticFiles to serve the static directory (it's already imported but unused).

This approach aligns with standard web development practices and will make the dashboard much easier to work on in the future.


PROJECT_ID = os.getenv("BQ_AGENT_ANALYTICS_PROJECT")
DATASET_ID = os.getenv("BQ_AGENT_ANALYTICS_DATASET")
TABLE_ID = os.getenv("BQ_AGENT_ANALYTICS_TABLE", "agent_events")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default table ID is set to "agent_events", which is inconsistent with the dashboard and simulation code where the default is "agent_events_v2". To ensure data is logged to the correct table by default when the BQ_AGENT_ANALYTICS_TABLE environment variable is not set, this should be updated.

Suggested change
TABLE_ID = os.getenv("BQ_AGENT_ANALYTICS_TABLE", "agent_events")
TABLE_ID = os.getenv("BQ_AGENT_ANALYTICS_TABLE", "agent_events_v2")

Comment on lines +72 to +79
def get_bq_client() -> bigquery.Client:
"""Get or create BigQuery client."""
if not PROJECT_ID:
raise HTTPException(
status_code=500,
detail="BQ_AGENT_ANALYTICS_PROJECT environment variable not set",
)
return bigquery.Client(project=PROJECT_ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

A new bigquery.Client is instantiated on every API call within get_bq_client(). This is inefficient as it can add overhead for authentication and resource initialization on each request. It's better to create a single client instance when the application starts and reuse it across all requests.

A simple way to fix this is to cache the result of this function. You can use @lru_cache from the functools module. You'll need to add from functools import lru_cache at the top of the file.

from functools import lru_cache

@lru_cache
def get_bq_client() -> bigquery.Client:
    # ... function body

Alternatively, you could manage the client's lifecycle using FastAPI's lifespan events.

@caohy1988 caohy1988 marked this pull request as draft January 27, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants